package cn.schoolwow.ams.module.block.listBlock.daoBlock.entityTable.api.flow;//package cn.schoolwow.ams.module.listener.operation.flow;

import cn.schoolwow.ams.module.block.listBlock.daoBlock.entityTable.initial.domain.EntityTableListBlockContext;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.Arrays;
import java.util.List;

public class ExecuteEntityTableListBlockDeleteFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        EntityTableListBlockContext entityTableListBlockContext = flowContext.checkInstanceData(EntityTableListBlockContext.class);
        String id = (String) flowContext.checkData("id");

        List<String> idList = Arrays.asList(id.split(",", -1));
        entityTableListBlockContext.dao.query(entityTableListBlockContext.entity.clazz)
                .addInQuery("id", idList)
                .execute()
                .delete();
    }

    @Override
    public String name() {
        return "执行EntityTableListBlock类型的刪除按钮";
    }

}
